package com.e3.basdoc.goodscls.client;

import java.util.List;

import com.e3.basdoc.goodscls.model.GoodsClsModel;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.google.gwt.user.client.rpc.AsyncCallback;

public class GoodsClsTreePanel extends TGFTreePanelAsync<GoodsClsModel> {
	
	private GoodsClsRPCServiceAsync service = GoodsClsRPCService.Util.getInstance();

	@Override
	public String getTreeDisplayFieldName() {
		return GoodsClsModel.NAME;
	}

	@Override
	public void onTreeLoadSuccess(GoodsClsModel parent, List<GoodsClsModel> result) {
		if(result!=null&&result.size()==1){
			GoodsClsModel model = result.get(0);
			if(GoodsClsHelper.INSTANCE.isRootModel(model)){
				model.setName(GoodsClsMessages.INSTANCE.tree_root_name());
			}
		}
	}

	@Override
	public void excuteLoadModelChildren(final GoodsClsModel pModel,AsyncCallback<List<GoodsClsModel>> callback) {
		service.getGoodsClsChildren(pModel,callback);
	}

	@Override
	public String getRootDisplayName() {
		return GoodsClsMessages.INSTANCE.tree_root_name();
	}

	@Override
	protected boolean isRootModel(GoodsClsModel model) {
		return GoodsClsHelper.INSTANCE.isRootModel(model);
	}

}
